//
//  MDDPersonViewController.m
//  com.modada.new
//
//  Created by ferver7 on 2019/3/9.
//  Copyright © 2019 ferver7. All rights reserved.
//

#import "MDDPersonViewController.h"
#import "MDDOrderViewController.h"

@interface MDDPersonViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *doorImageview;
@property (weak, nonatomic) IBOutlet UILabel *storeNameLabel;

@end

@implementation MDDPersonViewController
- (IBAction)allOrderAction:(id)sender {
    MDDOrderViewController * ovc = mGetStoryboardViewController(@"Main", @"mDDOrderViewController");
    ovc.index = 0;
    ovc.orderStatus = -1;
    NavigationController_pushVC(ovc);
}
- (IBAction)waitSendAction:(id)sender {
    MDDOrderViewController * ovc = mGetStoryboardViewController(@"Main", @"mDDOrderViewController");
    ovc.index = 1;
    ovc.orderStatus = 0;
    NavigationController_pushVC(ovc);
}
- (IBAction)waitReceiveAction:(id)sender {
    MDDOrderViewController * ovc = mGetStoryboardViewController(@"Main", @"mDDOrderViewController");
    ovc.index = 2;
    ovc.orderStatus = 10;
    NavigationController_pushVC(ovc);
}
- (IBAction)endOrderAction:(id)sender {
    MDDOrderViewController * ovc = mGetStoryboardViewController(@"Main", @"mDDOrderViewController");
    ovc.index = 3;
    ovc.orderStatus = 20;
    NavigationController_pushVC(ovc);
}

- (void)viewDidLoad {
    [super viewDidLoad];
    mNavitationTitle(@"个人中心");
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section != 0) {
        return 10;
    }else{
        return 0.01;
    }
}
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self getUserInfo];
}
-(void)getUserInfo
{
    NSMutableDictionary * info = [[NSMutableDictionary alloc]init];
    [PPNetworkHelper POST:app_getUserInfo parameters:info success:^(id responseObject) {
        if (YJPPSUCCESS(responseObject)) {
            AppUserBaseModel * appModel = [AppUserBaseModel sharedUserData];
            [appModel setValuesForKeysWithDictionary:responseObject[@"data"]];
            [AppUserBaseModel storeUserInfoWithModel:appModel];
            self.storeNameLabel.text = appModel.storeName;
            [self.doorImageview sd_setImageWithURL:[NSURL URLWithString:appModel.doorImage] placeholderImage:mImageByName(@"")];
        }else{
            
        }
    } failure:^(NSError *error) {
        
    } showLoading:nil];
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 2 && indexPath.row == 1) {
        NSString *callPhone = [NSString stringWithFormat:@"telprompt://%@", @"15116165121"];
        if (@available(iOS 10.0, *)) {
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone] options:@{} completionHandler:nil];
        } else {
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone]];
        }
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
